package org.dizem.freepl0.gui.menu;

import org.dizem.freepl0.gui.controller.FPController;

import javax.swing.*;

/**
 * Created by IntelliJ IDEA.
 * User: DIZEM
 * Date: 11-2-2
 * Time: 下午6:13
 */
public class FPToolBar extends JToolBar {
	private FPController controller;

	public FPToolBar(FPController controller) {
		this.controller = controller;
		this.add(makeButton("toolbar_open", "Open File", "res/open.png"));
		this.add(makeButton("toolbar_new", "New File", "res/new.png"));
		this.add(makeButton("toolbar_save", "Save all", "res/save.png"));
		this.addSeparator();
		this.add(makeButton("toolbar_undo", "Undo", "res/undo.png"));
		this.add(makeButton("toolbar_redo", "Redo", "res/redo.png"));
		this.addSeparator();
		this.add(makeButton("toolbar_cut", "Cut", "res/cut.png"));
		this.add(makeButton("toolbar_copy", "Copy", "res/copy.png"));
		this.add(makeButton("toolbar_paste", "Paste", "res/paste.png"));
		this.add(makeButton("toolbar_modify", "Modify", "res/modify.png"));
		this.addSeparator();
		this.add(makeButton("toolbar_run", "Run", "res/run.png"));
		this.addSeparator();
		this.add(makeButton("toolbar_about", "About", "res/about.png"));
	}

	private JButton makeButton(String id, String toolTop, String path) {
		JButton button = new JButton();
		button.setIcon(new ImageIcon(ClassLoader.getSystemResource(path)));
		button.setToolTipText(toolTop);
		button.addActionListener(controller.getListener());
		button.setName(id);
		return button;
	}
}
